package com.bilibili.juc.arthas;

import java.util.Arrays;

/**
 * 冒泡排序 : 两两交换，最大值往后排
 */
public class PaoSort {
    public static void main(String[] args) {
        int[] arr = {5,2,1,3};
        int length = arr.length;
        for (int i = 0; i < length-1; i++) {
            int ilen = length-i-1;
            for (int j = 0; j < ilen; j++) {
                if (arr[j] > arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }

        System.out.println(Arrays.toString(arr));
    }
}
